let shell = require('shelljs')
let name = process.argv[2] || 'Auto-commit' // message
let commitId = process.argv[3]  // commitId
let exec = shell.exec // 执行命令
let exit = shell.exit // 退出当前进程exit(1) 
let echo = shell.echo // 输出打印
if(commitId){
  exec(`git reset ${commitId}`)
}else{
  echo('Error: not have commitId, no need reset')
}
if (exec('git add .').code !== 0) {
  echo('Error: Git add failed')
  exit(1)
}
if (exec(`git commit -m "${name}"`).code !== 0) {
  echo('Error: Git commit failed')
  exit(1)
}
if (exec('git push -f').code !== 0) {
  echo('Error: Git commit failed')
  exit(1)
}
